//
//  Warrior.mm
//  FrameWork
//
//  Created by Eagle on 6/10/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "Warrior.h"
#import "Parameter.h"


@implementation Warrior

@synthesize level = _level;
@synthesize exp = _exp;
@synthesize levelExp = _levelExp;
@synthesize aniTime= _aniTime;
@synthesize interval = _interval;
@synthesize attackRadius = _attackRadius;
@synthesize guardRadius = _guardRadius;
@synthesize speed = _speed;
@synthesize attack = _attack;
@synthesize state = _state;
@synthesize target = _target;
@synthesize frame = _frame;
@synthesize end = _end;
@synthesize location = _location;
@synthesize nextLocation = _nextLocation;
@synthesize direction = _direction;
@synthesize isAngery = _isAngery;
@synthesize angeryTimeLeft = _angeryTimeLeft;


-(void)levelUp
{
	if (_level < 99) {
		_level++;
		self.levelExp = [[Parameter sharedParameter] warriorLevelExp:_level];
		self.interval = [[Parameter sharedParameter] warriorInterval:_level];
		self.attack = [[Parameter sharedParameter] warriorAttack:_level];
		self.attackRadius = [[Parameter sharedParameter] warriorAttackRadius:_level];
		self.guardRadius = [[Parameter sharedParameter] warriorGuardRadius:_level];
		self.speed = [[Parameter sharedParameter] warriorSpeed:_level];
	}
}

@end



@implementation Guanyu

+(id)warrior
{
	Guanyu* warrior = nil;
	if ((warrior = [super node])) 
	{
		warrior.level = 1;
		warrior.exp = 0; 
		warrior.levelExp = [[Parameter sharedParameter] warriorLevelExp:1];
		warrior.interval = [[Parameter sharedParameter] warriorInterval:1];
		warrior.attack = [[Parameter sharedParameter] warriorAttack:1];
		warrior.attackRadius = [[Parameter sharedParameter] warriorAttackRadius:1];
		warrior.guardRadius = [[Parameter sharedParameter] warriorGuardRadius:1];
		warrior.speed = [[Parameter sharedParameter] warriorSpeed:1];
		warrior.state = WARRIOR_STAND;
		warrior.target = nil;
		warrior.frame = 0;
		warrior.isAngery = NO;
		warrior.angeryTimeLeft = 0;
		
	}
	return warrior;
}



-(void)dealloc
{
	[super dealloc];
	if (_target) 
	{
		[_target release];
	}
	if (_end) 
	{
		[_end release];
	}
}

@end